from contextlib import ContextDecorator

class mycontext(ContextDecorator):
    def __enter__(self):
        print('Starting')
        return self

    def __exit__(self, *exc):
        print('Finishing')
        return False

# 使用示例
@mycontext()
def demo_function():
    print("Inside the function")

demo_function()